# -*- coding:utf-8 -*-
# @File       :   login_pgc_user.py
# @Author     :   LINING
# @Time       :   2024/8/7 11:16
# @Description :
import time

from TestCase.Pages.login.login_pgc_user import LoginPgcUser as lpu
from Handle.handle_js import skip_reptile


class LoginPgcUser:
    def __init__(self, page):
        self.page = page
        self.lpu = lpu(self.page)

    def click_login_button(self):
        self.lpu.click_login_button()

    def fill_user_name(self, user_name):
        self.lpu.fill_user_name(user_name)

    def fill_password(self, password):
        self.lpu.fill_password(password)

    def slider_verify(self):
        skip_reptile(self.page)
        self.lpu.slider_verify()

    def click_login(self):
        self.lpu.click_login()

    def login_success_user(self, user_name, password):
        # 登录组装
        self.click_login_button()
        self.fill_user_name(user_name)
        self.fill_password(password)
        self.slider_verify()
        self.click_login()
        for i in range(10):
            title = self.lpu.get_current_title()
            if '个人中心' in title:
                return
            time.sleep(1)

    # 获取登录是否成功
    def get_login_message(self, is_fail):
        """
        :param is_fail: 标记是失败用例还是成功用例
        :return:
        """
        if is_fail:
            return self.lpu.get_fail_message()
        else:
            return self.lpu.find_create_vedio()

